{extend name="base" /}
{block name="body"}
<div class="layui-card">
	<div class="layui-card-header">
		<form action="{:url('admin/metadata/index')}" class="layui-form" method="get">
			<div class="layui-form-item">
				<div class="layui-inline">
					名称
				</div>
				<div class="layui-inline">
					<input type="text" name="name" value="{:input('name')}" autocomplete="off" class="layui-input"/>
				</div>
				<div class="layui-inline">
					类型
				</div>
				<div class="layui-inline">
					<select name="meta_type">
						<option value="">全部分类</option>
						{foreach name="metadataType" item="v"}
						<option value="{$v.id}" {if condition="input('meta_type') eq $v.id" }selected="selected"{/if}>{$v.name}</option>
						{/foreach}
					</select>
				</div>
				<div class="layui-inline">
					<button class="layui-btn layui-btn-normal ajax-search"><i class="fa fa-search"></i></button>
				</div>
			</div>
		</form>
	</div>
	<div class="layui-btn-group">
		<a onclick="add()" class="layui-btn"><i class="fa fa-plus-circle"></i> 添加元数据</a>
	</div>
	<div class="layui-card-body">
		<table class="layui-table layui-form">
			<thead>
			<tr>
				<th>元数据名称</th>
				<th>元数据类型</th>
				<th>行数</th>
				<th>更新时间</th>
				<th>更新记录</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
			{foreach name="list" item="v" empty="$empty"}
			<tr>
				<td>{$v.name}</td>
				<td>{$v.typeName}</td>
				<td>{$v.line_count}</td>
				<td>{$v.last_time}</td>
				<td>{$v.last_time}</td>
				<td>
					<a onclick="edit({$v.id})" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 编辑</a>
					<a onclick="importData({$v.id})" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 导入数据</a>
				</td>
			</tr>
			{/foreach}
			</tbody>
		</table>
		<div class="page">{$list->render()}</div>
	</div>
</div>
{/block}
{block name="js"}
<script>
	function add() {
		layer.open({
			type: 2,
			title: '消息',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/metadata/add',
		});
	}

	function edit(data) {
		layer.open({
			type: 2,
			title: '消息',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/metadata/edit?id=' + data,
		});
	}

	function importData(data) {
		layer.open({
			type: 2,
			title: '消息',
			shadeClose: true,
			shade: false,
			area: ['600px', '480px'],
			content: '/admin/metadata/importData?id=' + data,
		});
	}
</script>
{/block}